<?php
class Login_Model extends Model {
	public function __construct() {
		parent::__construct();
	}
	public function doLogin() {
		$param = array(
			':email' => $_POST['email'],
			':password' => md5 ($_POST['password']) 
		);
		
		$strQuery = "SELECT name FROM user 
		         WHERE email=:email AND password=:password";
		$prepare = $this->db->prepare($strQuery);
		$prepare->execute($param);
		
		$count = $prepare->rowCount();
		if ($count > 0) {
			Session::init();
			Session::set('isLogin', true);
			header('location: ../dashboard');
		} else {
			header('location: ../login');
		}

		//$result = $prepare->fetchAll();		
		//echo "Name: " . $result[0]['name'];
	}
}
